#This file is adapted from http://www.scons.org/wiki/SconstructMultiple

import glob

#get all the build variables we need
Import('env', 'project', 'mymode', 'debugcflags', 'releasecflags')
localenv = env.Copy()

buildroot = '../' + mymode  #holds the root of the build directory tree
builddir = buildroot + '/' + project   #holds the build directory for this project
targetpath = builddir + '/' + 'csstidy'  #holds the path to the executable in the build directory

#append the user's additional compile flags
#assume debugcflags and releasecflags are defined
if mymode == 'debug':
    localenv.Append(CCFLAGS=debugcflags)
else:
    localenv.Append(CCFLAGS=releasecflags)

#specify the build directory
localenv.BuildDir(builddir, ".", duplicate=0)

#Figure out all the source files
srclst = map(lambda x: builddir + '/' + x, glob.glob('*.cpp'))

#If running win32 get special version information from the .rc
#if localenv['PLATFORM'] == 'win32':
#    resource = localenv.RES('win32_resource.rc')
#    srclst.append(resource)


localenv.Program(targetpath, source=srclst)
